package com.lynn.springboot_demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cl
 * @Date 2020/6/8 16:43
 * @Value 注解读取配置文件中的值，需要在类上使用@PropertySource("classpath:config.properties")
 * 注解指定读取哪个配置文件
 */
@RestController
@RequestMapping("/api/test")
@PropertySource("classpath:config.properties")
public class TestController {
    @Value("${solr.url}")
    private String string;

    @GetMapping("/test1")
    public void test() {
        //测试全局异常捕捉
        System.out.println(1 / 0);
        System.out.println(string);
    }
}
